local que_duanxing = fk.CreateSkill {
    name = "que_duanxing",
    anim_type = "offensive",
}
Fk:loadTranslationTable {
    ["que_duanxing"] = "断形",
    [":que_duanxing"] = "出牌阶段限一次，你可以选择一名其他角色，然后选择其手牌中的一个点数，其无法使用，打出和弃置该点数的牌直到你的下个准备阶段。",

    ["@que_duanxing_prohibit"] = "断形",
}
que_duanxing:addEffect("active", {
    anim_type = "offensive",
    card_num = 0,
    target_num = 1,
    prompt = "断形：你可以封禁一名角色手牌中的一个点数。",
    can_use = function(self, player)
        return player:usedSkillTimes(que_duanxing.name, Player.HistoryPhase) == 0 and not player:isNude()
    end,
    card_filter = Util.FalseFunc,
    target_filter = function(self, player, to_select, selected, cards)
        return #selected == 0 and to_select ~= player
    end,
    on_use = function(self, room, effect)
        local player = effect.from
        local chc = {}
        for _, i in ipairs(effect.tos[1]:getCardIds("h")) do
            local num = tostring(Fk:getCardById(i).number)
            table.insertIfNeed(chc, num)
        end
        if #chc == 0 then return end
        local chs = room:askToChoice(player, {
            choices = chc,
            skill_name = que_duanxing.name,
            prompt = "断形：请选择要禁用的点数",
        })
        room:setPlayerMark(effect.tos[1], "@que_duanxing_prohibit", tonumber(chs))
        room:throwCard(effect.cards, que_duanxing.name, player, player)
    end,
})
que_duanxing:addEffect(fk.EventPhaseEnd, {
    can_refresh = function(self, event, target, player, data)
        return target == player and player:hasSkill(que_duanxing.name) and player.phase == Player.Start and
            table.find(player.room.alive_players, function(p)
                return p:getMark("@que_duanxing_prohibit") ~= 0
            end)
    end,
    on_refresh = function(self, event, target, player, data)
        local room = player.room
        for _, p in ipairs(room.alive_players) do
            if p:getMark("@que_duanxing_prohibit") ~= 0 then
                room:setPlayerMark(p, "@que_duanxing_prohibit", 0)
            end
        end
    end,
})
que_duanxing:addEffect("prohibit", {
    prohibit_use = function(self, player, card)
        local n = player:getMark("@que_duanxing_prohibit")
        if player:getMark("@que_duanxing_prohibit") == "A" then
            n = 1
        elseif player:getMark("@que_duanxing_prohibit") == "J" then
            n = 11
        elseif player:getMark("@que_duanxing_prohibit") == "Q" then
            n = 12
        elseif player:getMark("@que_duanxing_prohibit") == "K" then
            n = 13
        end
        return player:getMark("@que_duanxing_prohibit") ~= 0 and card.number == player:getMark("@que_duanxing_prohibit")
    end,
    prohibit_response = function(self, player, card)
        local n = player:getMark("@que_duanxing_prohibit")
        if player:getMark("@que_duanxing_prohibit") == "A" then
            n = 1
        elseif player:getMark("@que_duanxing_prohibit") == "J" then
            n = 11
        elseif player:getMark("@que_duanxing_prohibit") == "Q" then
            n = 12
        elseif player:getMark("@que_duanxing_prohibit") == "K" then
            n = 13
        end
        return player:getMark("@que_duanxing_prohibit") ~= 0 and card.number == player:getMark("@que_duanxing_prohibit")
    end,
    prohibit_discard = function(self, player, card)
        local n = player:getMark("@que_duanxing_prohibit")
        if player:getMark("@que_duanxing_prohibit") == "A" then
            n = 1
        elseif player:getMark("@que_duanxing_prohibit") == "J" then
            n = 11
        elseif player:getMark("@que_duanxing_prohibit") == "Q" then
            n = 12
        elseif player:getMark("@que_duanxing_prohibit") == "K" then
            n = 13
        end
        return player:getMark("@que_duanxing_prohibit") ~= 0 and card.number == player:getMark("@que_duanxing_prohibit")
    end,
})
return que_duanxing
